#!/usr/bin/env python
# coding=utf-8
# Created by zhezhiyong@163.com on 2017/3/9.

from tgrocery import Grocery

from tgrocery_util import dir_list

# load
# grocery name must be the same as the previous one
new_grocery = Grocery('test')
new_grocery.load()
#
file_list = dir_list('deal')

text_src = []
for f in file_list:
    with open(f, 'r') as f:
        for line in f:
            pos = line.find(':')
            print line[:pos], line[pos + 1:]
        text_src = [[line[:pos], line[pos + 1:]] for line in f]
for flag, txt in text_src:
    # print flag, txt
    test_flag = new_grocery.predict(txt)
    print '真实', flag, '预测', test_flag, '是否准确', flag is test_flag
